<template>
  <div class="echarts-outer-wrapper flex-cloumn width-410">
    <Title title="排行榜" dw="单位：亿元"></Title>
    <div class="title-scroll">
      <div
        class="scrollTable_title text-c"
        v-for="(item, index) in scrollTabList"
        :key="index"
        :class="{ scrollTable_title_active: tabIndex === index }"
        v-text="item.tabValue"
        @click="scrollTabItem(item, index)"
      ></div>
    </div>
    <div class="flex1" style="padding: 4px 0">
      <vue-seamless-scroll
        :data="swiperListMiddle"
        :class-option="classOptionMiddle"
        class="table-wrapper"
      >
        <div
          class="scrollItem"
          v-for="(item, index) in swiperListMiddle"
          :key="index"
        >
          <img
            src="~@/assets/images/icon-px-one.png"
            style="width: 21px; height: 17px"
            v-if="index === 0"
          />
          <img
            src="~@/assets/images/icon-px-two.png"
            style="width: 21px; height: 17px"
            v-if="index === 1"
          />
          <img
            src="~@/assets/images/icon-px-three.png"
            style="width: 21px; height: 17px"
            v-if="index === 2"
          />
          <div class="scrollIndex" style="width: 21px" v-if="index > 2">
            {{ index + 1 }}
          </div>
          <div class="scrollName">
            {{ item.scrollNameValue }}
          </div>
          <div class="scrollNumber money" style>{{ item.scrollNumberVal }}</div>
          <div class="scrollNumber">{{ item.scrollNumberVal01 }}</div>
        </div>
      </vue-seamless-scroll>
    </div>
  </div>
</template>

<script>
import Title from "@/components/title";

export default {
  name: "sstjyz",
  components: {
    Title,
  },
  data() {
    return {
      prevDate: "",
      EchartData: [],
      yearDate: "",
      tabIndex: 0,
      scrollTabList: [
        {
          tabValue: "入库分税种前10名",
        },
        {
          tabValue: "征收所前10名",
        },
        {
          tabValue: "入库分行业前10名",
        },
        {
          tabValue: "分纳税人前10名",
        },
      ],
      swiperListMiddle: [],
      classOptionMiddle: {
        limitMoveNum: 1, // 开启无缝滚动的数据量
        singleHeight: 128,
        waitTime: 0,
        step: 0.5,
        hoverStop: true,
      },
    };
  },
  created() {
    let date = "";
    let month = new Date().getMonth() + 1;
    let year = new Date().getFullYear();
    date = year + "-" + month;
    this.prevDate = date;
    this.yearDate = year;
  },
  mounted() {
    this.ajax({
      url: "/dpzsSycxService/sstjyzQuery",
      method: "post",
      data: {
        param: {
          tjnd: this.yearDate,
        },
      },
    }).then((res) => {
      res = res.data;
      if (res.rtnCode !== "200") {
        this.$message.error(res.rtnMsg);
        return;
      }
      this.EchartData = res.data;
      this.scrollTabItem(this.scrollTabList[this.tabIndex], this.tabIndex);
    });
  },
  methods: {
    scrollTabItem(item, index) {
      this.tabIndex = index;
      switch (item.tabValue) {
        case "征收所前10名":
          this.swiperListMiddle = this.EchartData.zssList.map((item) => {
            return {
              scrollNameValue: item.zgksmc,
              scrollNumberVal: item.je,
              scrollNumberVal01: item.zb,
            };
          });
          break;
        case "入库分税种前10名":
          this.swiperListMiddle = this.EchartData.fszList.map((item) => {
            return {
              scrollNameValue: item.szmc,
              scrollNumberVal: item.je,
              scrollNumberVal01: item.zb,
            };
          });
          break;
        case "入库分行业前10名":
          this.swiperListMiddle = this.EchartData.fhyList.map((item) => {
            return {
              scrollNameValue: item.hymc,
              scrollNumberVal: item.je,
              scrollNumberVal01: item.zb,
            };
          });
          break;
        case "分纳税人前10名":
          this.swiperListMiddle = this.EchartData.fnsrList.map((item) => {
            return {
              scrollNameValue: item.nsrmc,
              scrollNumberVal: item.je,
              scrollNumberVal01: item.zb,
            };
          });
          break;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "~@/assets/styles/mixin.scss";

.echarts-outer-wrapper {
  width: 458px;
  height: 314px;
}

.ItemRightMiddle_bom_title {
  width: 458px;
  height: 28px;
}

.title-scroll {
  flex: 0 0 40px;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  @include scrollStyle;

  .scrollTable_title {
    height: 40px;
    line-height: 40px;
    padding: 0 24px;
    font-size: 16px;
    color: rgba(128, 194, 255, 0.29);
    cursor: pointer;
    white-space: nowrap;
  }

  .scrollTable_title_active {
    font-size: 18px;
    color: #a1d2ff;
    background: url("~@/assets/images/bg-22.png") left bottom no-repeat;
    background-size: 100% 30px;
  }
}

.table-wrapper {
  padding: 0px 40px;
  height: 212px;
  overflow: hidden;

  .scrollItem {
    padding: 0 12px;
    display: flex;
    align-items: center;
    height: 28px;
    background-image: url(~@/assets/images/bg-23.png);
    background-size: 100% 20px;
    background-position: center bottom;
    background-repeat: no-repeat;
    margin-bottom: 10px;

    .scrollIndex {
      font-size: 10px;
      color: #e4cb2c;
      text-align: center;
    }

    .scrollName {
      padding: 0 12px;
      flex: 1;
      white-space: nowrap;
      overflow: hidden;
      text-emphasis: ellipsis;
      font-size: 14px;
      color: #ffffff;
    }

    .scrollNumber {
      font-size: 14px;
      color: #0cd2ea;
      width: 70px;
      overflow: hidden;
      text-align: right;

      &.money {
        color: #fbe671;
      }
    }
  }
}
</style>
